#include <iostream>
#include <string>
#include <unordered_map>
#include <map>
#include "splitTool.h"
#include "inicpp.hpp"
#include "simhash/Simhasher.hpp"
using namespace simhash;
using std::string;
using std::map;
using std::unordered_map;

struct RssDoc
{
    string docid;
    string description;
};

class PageLibPrecessor
{
public:
    PageLibPrecessor(SplitTool* cuttor, inicpp::IniManager* ini);

    void cutRedundantPage();//创建去重网页库
    void invertedIndex();//创建倒排索引库
    
    //计算单个字符串(搜索框内容)的向量
    void calculateSearchContentWeight(vector<string> &searchKeyWords);

public:
    //成员对象的方法
    void _cuttor_cutCnString(string str, vector<string> &words, int placeholder);
    string _ini_config(string conf);


private:
    void readPage(string filename);
    map<string,int> calculateTF(string webContent);//返回一个page中所有词的TF
    void calculateWeight(map<string,int> &tfs, int docid);
    void getDFs();
    void getLineCount();



private:
    set<uint64_t> _webSimhash;//存储每个page的simhash值
    unordered_map<string,set<pair<int,double>>> _invertIndexLib;
    map<string,int> _DFs;//map<词，<这个词出现在几个page中>
    map<int,double> _wp;//存储每个page的根号下w^2之和
    int _pageCount;

    SplitTool* _cuttor;//分词对象
    inicpp::IniManager* _ini;

};